package com.atguigu.wordcount.commonfriend;

import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;


/**
 * @ClassName ReducerCF1
 * @DeScription ReducerCF1
 * @Author 剧情再美终是戏
 * @Date 2019/11/20 17:18
 * @Version 1.0
 **/
// 输入 B:A C:A D:A B:C
// 输出 B:A,C
public class ReducerCF1 extends Reducer<Text, Text, Text, Text> {

    private Text out_value = new Text();

    @Override
    protected void reduce(Text key, Iterable<Text> values, Context context) throws IOException, InterruptedException {
        StringBuffer sb = new StringBuffer();
        for (Text value : values) {
            sb.append(value + ",");
        }
        out_value.set(sb.toString());
        context.write(key, out_value);
    }
}
